//
//  ChooseContactsTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/13.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "ChooseContactsTableViewCell.h"
#import "FriendModel.h"

@implementation ChooseContactsTableViewCell
- (void)setFriendWithModel:(FriendModel *)model
{
    self.titleLabel.text = model.nickname;

}

- (UIImageView *)iconImageView
{
    if(!_iconImageView)
    {
        UIView *superView = self.contentView;
        _iconImageView = [[UIImageView alloc]init];
        [superView addSubview:_iconImageView];
        _iconImageView.layer.cornerRadius = px1920Height(140)/2;
        _iconImageView.layer.masksToBounds = YES;
    }
    return _iconImageView;
}


- (UILabel *)titleLabel
{
    if(!_titleLabel)
    {
        UIView *superView = self.contentView;
        _titleLabel = [[UILabel alloc]init];
        [superView addSubview:_titleLabel];
        [_titleLabel setFont:fontCommonSize];
        [_titleLabel setTextColor:[UIColor whiteColor]];
    }
    return _titleLabel;
}


- (UIButton *)selectedButton
{
    if(!_selectedButton)
    {
        UIView *superView = self.contentView;
        _selectedButton = [[UIButton alloc]init];
        [superView addSubview:_selectedButton];
        [_selectedButton setImage:imageWithName(@"but_select") forState:UIControlStateNormal];
        [_selectedButton setImage:imageWithName(@"but_select_pre") forState:UIControlStateSelected];
        _selectedButton.userInteractionEnabled = NO;
    }
    return _selectedButton;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    superView.backgroundColor = rgba(27,44,81,1);
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1920Height(40));
        make.height.width.mas_equalTo(px1920Height(140));
    }];

    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(_iconImageView.mas_right).with.offset(px1920Height(40));
        make.width.mas_equalTo(px1080Width(600));
    }];
    
    [self.selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1920Height(40));
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
